<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'MyJsp.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!-- 项目前置 -->
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="css/iconfont.css">
<link rel="stylesheet" href="css/global.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/swiper.min.css">
<link rel="stylesheet" href="css/styles.css">
<script src="js/jquery.1.12.4.min.js" charset="UTF-8"></script>
<script src="js/bootstrap.min.js" charset="UTF-8"></script>
<script src="js/swiper.min.js" charset="UTF-8"></script>
<script src="js/global.js" charset="UTF-8"></script>
<script src="js/jquery.DJMask.2.1.1.js" charset="UTF-8"></script>
<!-- 项目前置 -->
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script src="js/address.js" charset="UTF-8"></script>

</head>

<body>
	<%@include file="personal_top.jsp"%>
	<div class="content clearfix bgf5">
		<section class="user-center inner clearfix">
		<div class="pull-left bgf">
			<a href="index.jsp" class="title">U袋欢迎页</a>
			<dl class="user-center__nav">
				<dt>帐户信息</dt>
				<a href="udai_setting.html"><dd>个人资料</dd></a>
				<a href="udai_treasurer.html"><dd>资金管理</dd></a>
				<a href="udai_integral.html"><dd>积分平台</dd></a>
				<a href="udai_address.html"><dd class="active">收货地址</dd></a>
				<a href="udai_coupon.html"><dd>我的优惠券</dd></a>
				<a href="udai_paypwd_modify.html"><dd>修改支付密码</dd></a>
				<a href="udai_pwd_modify.html"><dd>修改登录密码</dd></a>
			</dl>
			<dl class="user-center__nav">
				<dt>订单中心</dt>
				<a href="udai_order.html"><dd>我的订单</dd></a>
				<a href="udai_collection.html"><dd>我的收藏</dd></a>
				<a href="udai_refund.html"><dd>退款/退货</dd></a>
			</dl>
			<dl class="user-center__nav">
				<dt>服务中心</dt>
				<a href="udai_mail_query.html"><dd>物流查询</dd></a>
				<a href=""><dd>数据自助下载</dd></a>
				<a href="temp_article/udai_article1.html"><dd>售后服务</dd></a>
				<a href="temp_article/udai_article2.html"><dd>配送服务</dd></a>
				<a href="temp_article/udai_article3.html"><dd>用户协议</dd></a>
				<a href="temp_article/udai_article4.html"><dd>常见问题</dd></a>
			</dl>
			<dl class="user-center__nav">
				<dt>新手上路</dt>
				<a href="temp_article/udai_article5.html"><dd>如何成为代理商</dd></a>
				<a href="temp_article/udai_article6.html"><dd>代销商上架教程</dd></a>
				<a href="temp_article/udai_article7.html"><dd>分销商常见问题</dd></a>
				<a href="temp_article/udai_article8.html"><dd>付款账户</dd></a>
			</dl>
			<dl class="user-center__nav">
				<dt>XXX</dt>
				<a href="temp_article/udai_article10.html"><dd>企业简介</dd></a>
				<a href="temp_article/udai_article11.html"><dd>加入U袋</dd></a>
				<a href="temp_article/udai_article12.html"><dd>隐私说明</dd></a>
			</dl>
		</div>
		
		
		<!-- 地址信息模块 -->
		<div class="pull-right">
			<div class="user-content__box clearfix bgf">
				<div class="title">账户信息-编辑收货地址</div>
				<form action="" class="user-addr__form form-horizontal" role="form" method="post">
					<p class="fz18 cr">
						编辑收货地址<span class="c6" style="margin-left: 20px">均为必填项</span>
					</p>
					<div class="form-group">
						<label for="name" class="col-sm-2 control-label">收货人姓名：</label>
						<div class="col-sm-6">
							<input class="form-control" id="aname" name="aname" value=""
								placeholder="请输入姓名" type="text">
						</div>
					</div>
					<div class="form-group">
						<label for="details" class="col-sm-2 control-label">收货地址：</label>
						<div class="col-sm-10">
							<div class="addr-linkage">
							<!-- 省份 -->
								<select name="province" id="province">
							
								</select>
								<!-- 城市 -->
								 <select name="city" id="city">
								
								 </select>
								 <!-- 区级 -->
								<select name="area" id="area">
								
								</select>
								<!-- 街道 -->
								 <select name="town" id="town">
								
								 </select>
							</div>
							<input class="form-control" id="details" name="details"
								placeholder="建议您如实填写详细收货地址，例如街道名称，门牌号码等信息" maxlength="30"
								value="" type="text">
						</div>
					</div>
					<!-- <div class="form-group">
							<label for="code" class="col-sm-2 control-label">地区编码：</label>
							<div class="col-sm-6">
								<input class="form-control" id="code" placeholder="请输入邮政编码" type="text">
							</div>
						</div> -->
					<div class="form-group">
						<label for="mobile" class="col-sm-2 control-label">手机号码：</label>
						<div class="col-sm-6">
							<input class="form-control" id="uphone" name="uphone" value="${user.uphone} "
								placeholder="请输入手机号码" type="text" readonly="readonly">
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-6">
							<div class="checkbox">
								<label><input type="checkbox" value="1" name="default" id="default"><i></i>
									设为默认收货地址</label>
							</div>
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-6">
							<button type="bottom" class="but" onclick="save()">保存</button>
						</div>
					</div>
					<script src="js/jquery.citys.js"></script>
					 <script>
						$(document)
								.ready(
										function() {
											// 添加街道/乡镇
											function townFormat(info) {
												$(
														'.addr-linkage select[name="town"]')
														.hide().empty();
												if (info['code'] % 1e4
														&& info['code'] < 7e6) { //是否为“区”且不是港澳台地区
													var ajaxConfig = {
														url : 'http://passer-by.com/data_location/town/'
																+ info['code']
																+ '.json',
														scriptCharset : 'UTF-8',
														dataType : "json",
														timeout : 4000,
														success : function(data) {
															$(
																	'.addr-linkage select[name="town"]')
																	.show();
															// $('#code').val(info['code']) // 填地区编码
															for (i in data) {
																$(
																		'.addr-linkage select[name="town"]')
																		.append(
																				'<option value="' + data[i] + '">'
																						+ data[i]
																						+ '</option>');
															}
															;
															$(
																	'.addr-linkage select[name="town"]')
																	.find(
																			'option[value="洪山镇"]')
																	.prop(
																			"selected",
																			"selected");
														},
													};
													$
															.ajax(ajaxConfig)
															.fail(
																	function(
																			p1,
																			p2,
																			p3) {
																		ajaxConfig.url = 'js/data_location/town/'
																				+ info['code']
																				+ '.json';
																		$
																				.ajax(ajaxConfig)
																	});
												}
											}
											;
											$('.addr-linkage')
													.citys(
															{
																// 如果某天这个仓库地址失效了dataUrl请使用本地 2017.10 的数据 'js/data_location/list.json'
																dataUrl : 'http://passer-by.com/data_location/list.json',
																spareUrl : 'js/data_location/list.json',
																dataType : 'json',
																valueType : 'name',
																province : '福建省',
																city : '福州市',
																area : '鼓楼区',
																onChange : function(
																		data) {
																	townFormat(data)
																},
															},
															function(api) {
																var info = api
																		.getInfo();
																townFormat(info);
															});
										});
					</script> 
				</form>
				<p class="fz18 cr">已保存的有效地址</p>

				<div class="table-thead addr-thead">
					<div class="tdf1">收货人</div>
					
					<div class="tdf3">
						<div class="tdt-a_l">详细地址</div>
					</div>
					<!-- <div class="tdf1">邮编</div> -->
					<div class="tdf1">电话/手机</div>
					<div class="tdf1">操作</div>
					<div class="tdf1"></div>
				</div>
				<div class="addr-list" id="aitemdiv">
				<c:forEach items="${alist }" var="a" varStatus="status">				     
				      <div class="addr-item" id="aitem${status.index}" >
			
						<div class="tdf1">${a.aname}</div>
						<div class="tdf3 tdt-a_l">${a.uaddress}</div>
						
						<div class="tdf1">${user.uphone}</div>
						<div class="tdf1 order">
							<a href="javascript:void(0)" onclick="adelete(${status.index})">删除</a>
						</div>
						<c:if test="${a.adefault==1}">
						<div class="tdf1">
							<a href="javascript:void(0)" class="default active" >默认地址</a>
						</div>
						</c:if>
						<c:if test="${a.adefault==0}">
						<div class="tdf1">
						<a href="javascript:void(0)" class="default" onclick="updateDefault(${status.index})">设为默认</a>
						</div>
						</c:if>
					</div>
				   </c:forEach>
				</div>
			</div>
		</div>
		</section>
	</div>
	<%@include file="bottom.jsp"%>
</body>
</html>
